<template>
	
	<view class="content" v-if="pageshow">
		<u-search placeholder="请输入姓名或公司名称进行搜索" v-model="keyword" @search="search" @custom="search"></u-search>

	    <view class="books">
					<view class="kg" style="margin-left: -10px; margin-right: -10px;"></view>
			<block v-for="(item,index) in list" :key="index">
			<view class="item" @click="jump('/pages/books/view?id='+item.id)">
				<view class="item_left">
					<u-avatar size='large' :src="item.avatarUrl"></u-avatar>
				</view>
				<view class="item_right">
					<view class="name">{{item.realname}}</view>
					<view class="desc">
						<view>{{item.company}}</view>
						<view class="banji">{{item.grade+item.class}}</view>
						</view>
				</view>
				
			</view>
				<u-line color="#F1F1F1" />
			</block>
			
			<u-loadmore v-if="!nodata" :load-text="loadText" :status="status" icon-type="flower" margin-top="20"
				margin-bottom="20" />
				
				 <u-empty text=" 暂无数据" mode="list" v-if="nodata"></u-empty>
		</view>
		<foot></foot>
		
		
		<auth :isauth="check_auth"></auth>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				keyword:"",
				status: 'loadmore',
				page: 1,
				nodata: false,
				loadText: {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '实在没有了'
				},
				pageshow: false,
				list: [],
				
			}
		},
	
		onShow(){
	
         this.item_list()
		},
	onPullDownRefresh() {
		this.page=1
		this.nodata=false
		this.item_list()
	},
		onReachBottom() {
			if (this.status != 'loadmore') {
				return;
			}
			this.status = "loading"
			this.page++;
			this.item_list()
		},
		methods: {
			search(){
				this.nodata=false
				this.page=1;
				this.item_list()
			},
			item_list() {
				this.$u.post('index.php?mod=app&act=list&table=user', {
					limit: 15,
					xcxkey:this.keyword,
					page: this.page,
					xcx:1
				}).then(res => {
					uni.stopPullDownRefresh();
					
					this.pageshow = true
					this.active = false
					let total = res.count
					this.count = res.count
					
					if (this.page == 1)
						this.list = res.data
					else
						this.list = this.list.concat(res.data)
			      
					if (total == this.list.length) {
			
						if (this.list.length == 0) {
							this.nodata = true
						} else
							this.status = "nomore"
						//this.loadText.nomore = (this.total > res.pagesize) ? "实在没有了" : ""
					} else {
						this.status = "loadmore"
					}
			
				});
			}
		}
	}
</script>

<style>
	.name{font-size: 16px; margin-bottom: 20rpx;}
	.desc{width:100%;
	font-size:14px ;
	color: #808080; 
	display: flex;
	align-items: center;
	justify-content: space-between;
	}
	.banji{color:#DD524D}
	.books{margin-top: 30rpx;}
 .content{padding: 20rpx;}
 .item{margin: 30rpx auto;display: flex;}
 .item_left{}
 .item_right{width:100%;display: flex;flex-direction: column; margin-left: 10px; justify-content: center;}
</style>
